<?php
/**
 *
 *
 */
namespace Yz\modules\Uploads;
class Controller_Upload
    extends \Yz_Controller_Templated
    implements \Yz_Controller_Interface
{

    /**
     *
     */
    protected function doGET()
    {
        debug();
        $template = $this->selectTemplate("form");

        $this->outputTemplate($template);
        return $this;
    }


    /**
     *
     */
    public function doPOST()
    {
        $upload = $this->module->selectModel("Upload");
        try {
            $item = $upload->processUpload('theUpload');

            $upload->addItem($item);

            $template = $this->selectTemplate('uploadComplete');
            $template->upload = $item;
        } catch (Exception_UploadFailed $ex) {

            $template = $this->selectTemplate('uploadFailed');
            $template->error = $ex;
        }
        $this->getView()->setCacheable(false);
        $this->outputTemplate($template);
        return $this;
    }

}
